import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/* Router Modules
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'
*/

/** note: Submenu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/

export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: 'dashboard', icon: 'dashboard', noCache: true }
      }
    ]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/radar',
    component: Layout,
    redirect: 'noredirect',
    name: 'radar',
    meta: {
      title: 'radar',
      icon: 'radar',
      roles: ['admin', 'qixiang']
    },
    children: [
      {
        path: 'MOASIC210',
        component: () => import('@/views/radar/MOASIC210'),
        name: 'cinrad-MOASIC210',
        meta: { title: 'MOASIC210', roles: ['admin', 'business'] }
      },
      {
        path: 'PPI19',
        component: () => import('@/views/radar/PPI19'),
        name: 'cinrad-PPI19',
        meta: { title: 'PPI19' }
      },
      {
        path: 'PPI26',
        component: () => import('@/views/radar/PPI26'),
        name: 'cinrad-PPI26',
        meta: { title: 'PPI26' }
      },
      {
        path: 'MAX37',
        component: () => import('@/views/radar/CR37'),
        name: 'cinrad-CR37',
        meta: { title: 'CR37' }
      },
      {
        path: 'TOPS41',
        component: () => import('@/views/radar/TOPS41'),
        name: 'cinrad-TOPS41',
        meta: { title: 'TOPS41' }
      },
      {
        path: 'VIL57',
        component: () => import('@/views/radar/VIL57'),
        name: 'cinrad-VIL57',
        meta: { title: 'VIL57' }
      },
      {
        path: 'HI59',
        component: () => import('@/views/radar/HI59'),
        name: 'cinrad-HI59',
        meta: { title: 'HI59' }
      },
      {
        path: 'M60',
        component: () => import('@/views/radar/M60'),
        name: 'cinrad-M60',
        meta: { title: 'M60' }
      },
      {
        path: 'TVS61',
        component: () => import('@/views/radar/TVS61'),
        name: 'cinrad-TVS61',
        meta: { title: 'TVS61' }
      },
      {
        path: 'OHP78',
        component: () => import('@/views/radar/OHP78'),
        name: 'cinrad-OHP78',
        meta: { title: 'OHP78' }
      },
      {
        path: 'THP79',
        component: () => import('@/views/radar/THP79'),
        name: 'cinrad-THP79',
        meta: { title: 'THP79' }
      },
      {
        path: 'ZDR158',
        component: () => import('@/views/radar/ZDR158'),
        name: 'cinrad-ZDR158',
        meta: { title: 'ZDR158' }
      },
      {
        path: 'PhiDP160',
        component: () => import('@/views/radar/PhiDP160'),
        name: 'cinrad-PhiDP160',
        meta: { title: 'PhiDP160' }
      },
      {
        path: 'KDP162',
        component: () => import('@/views/radar/KDP162'),
        name: 'cinrad-KDP162',
        meta: { title: 'KDP162' }
      },
      {
        path: 'HCL164',
        component: () => import('@/views/radar/HCL164'),
        name: 'cinrad-HCL164',
        meta: { title: 'HCL164' }
      }
    ]
  },
  {
    path: '/comb',
    component: Layout,
    redirect: 'noredirect',
    name: 'radarcomb',
    meta: {
      title: 'radarcomb',
      icon: 'radar',
      roles: ['admin', 'qixiang']
    },
    children: [
      {
        path: 'Union2',
        component: () => import('@/views/radar/Union2'),
        name: 'cinrad-union2',
        meta: { title: 'Union2' }
      },
      {
        path: 'Union4',
        component: () => import('@/views/radar/Union4'),
        name: 'cinrad-union4',
        meta: { title: 'Union4' }
      },
      {
        path: 'Overlay',
        component: () => import('@/views/radar/Overlay'),
        name: 'cinrad-overlay',
        meta: {
          title: 'Overlay'
        }
      },
      {
        path: 'Overlay2',
        component: () => import('@/views/radar/Overlay2'),
        name: 'cinrad-overlay2',
        meta: {
          title: 'Overlay2'
        }
      },
      {
        path: 'Overlay4',
        component: () => import('@/views/radar/Overlay4'),
        name: 'cinrad-overlay4',
        meta: {
          title: 'Overlay4'
        }
      },
      {
        path: 'Free',
        component: () => import('@/views/radar/Comb2'),
        name: 'cinrad-comb2',
        meta: { title: 'Comb2' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]
